package com.web.dao.impl;


import com.entity.Activitytype;
import com.entity.Activitytype;
import com.entity.Festival;
import com.mapper.ActivitytypeMapper;
import com.page.PageInfo;
import com.web.dao.ActivitytypeDao;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository("ActivitytypeDao")
public class ActivitytypeDaoImpl implements ActivitytypeDao {
    @Resource
    ActivitytypeMapper activitytypeMapper;

    public List<Activitytype> getAll() throws Exception {
        return activitytypeMapper.getAll();
    }

    public Activitytype selectByPrimaryKey(int atid) throws Exception {
        return activitytypeMapper.selectByPrimaryKey(atid);
    }
    
    public List<Activitytype> getActivitytypesByPage(PageInfo pageInfo) throws Exception {
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("currPage",pageInfo.getCurrPage());
        map.put("pageSize",pageInfo.getPageSize());
        int itemCount = (int)activitytypeMapper.countByExample(null);
        pageInfo.setItemCount(itemCount);
        return activitytypeMapper.getActivitytypesByPage(map);
    }

    public int add(Activitytype activitytype) throws Exception {
        return activitytypeMapper.insertSelective(activitytype);
    }

    public int update(Activitytype activitytype) throws Exception {
        return activitytypeMapper.updateByPrimaryKeySelective(activitytype);
    }
}
